<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 语音消息表
 */
class CreateWxmsgVoice extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wxmsg_voices', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->string('appid', 64)->default('')->comment('微信应用ID');
            $table->string('msg_type', 50)->default('')->comment('消息类型');
            $table->string('msg_id', 80)->default('')->comment('消息id');
            $table->string('to_user_name', 100)->default('')->comment('开发者微信号');
            $table->string('from_user_name', 150)->default('')->comment('发送方帐号');
            $table->string('media_id', 100)->default('')->comment('语音消息媒体id，可以调用多媒体文件下载接口拉取数据');
            $table->string('format', 30)->default('')->comment('语音格式，如amr，speex等');
            $table->timestamp('create_time')->comment('消息创建时间');
            $table->softDeletes();
            $table->timestamps();
            $table->index(['appid','from_user_name','deleted_at','create_time'], 'idx_1');
            $table->index(['appid','msg_id','deleted_at'], 'idx_2');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wxmsg_voices');
    }
}
